﻿CREATE TABLE [dbo].[Compras] (
    [IdCompra]           INT             IDENTITY (1, 1) NOT NULL,
    [IdTipoComprobante]  TINYINT         NOT NULL,
    [IdProveedor]        INT             NOT NULL,
    [Numero]             VARCHAR (20)    NOT NULL,
    [ProveedorDomicilio] VARCHAR (50)    NOT NULL,
    [ProveedorTelefono]  VARCHAR (50)    NOT NULL,
    [DescuentoRecargo]   DECIMAL (19, 4) NOT NULL,
    [Observaciones]      VARCHAR (500)   NOT NULL,
    [AjusteSubTotal]     DECIMAL (19, 4) NOT NULL,
    [AjusteIva]          DECIMAL (19, 4) NOT NULL,
    [AjusteImpuestos]    DECIMAL (19, 4) NOT NULL,
    [AjusteTotal]        DECIMAL (19, 4) NOT NULL,
    [EstaAjustado]       BIT             NOT NULL,
    [EstaEliminado]      BIT             CONSTRAINT [DF_Compras_EstaEliminado] DEFAULT ((0)) NOT NULL,
    CONSTRAINT [PK_Compras] PRIMARY KEY CLUSTERED ([IdCompra] ASC),
    CONSTRAINT [FK_Compras_Proveedores] FOREIGN KEY ([IdProveedor]) REFERENCES [dbo].[Proveedores] ([IdProveedor]),
    CONSTRAINT [FK_Compras_TiposComprobantes] FOREIGN KEY ([IdTipoComprobante]) REFERENCES [dbo].[TiposComprobantes] ([IdTipoComprobante])
);



